<%@ page contentType="text/html" pageEncoding="UTF-8"%>
<%@ include file="../header.jsp"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>${systemName }</title>
    <link rel="shortcut icon" href="${contextPath}/resources/favicon.ico"> 
    <link href="${contextPath}/resources/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="${contextPath}/resources/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <!-- Data Tables -->
    <link href="${contextPath}/resources/css/plugins/dataTables/dataTables.bootstrap.css" rel="stylesheet">
    <link href="${contextPath}/resources/css/animate.min.css" rel="stylesheet">
    <link href="${contextPath}/resources/css/style.min.css?v=4.1.0" rel="stylesheet">
    <!-- FooTable -->
    <link href="${contextPath}/resources/css/plugins/footable/footable.core.css" rel="stylesheet">
</head>
<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
       <div class="row">
          <div class="col-lg-12">
              <div class="ibox float-e-margins">
                  <div class="ibox-title">
                      <form role="form" class="form-inline" action="${contextPath }/system/good/list">
                          <div class="form-group">
                              <input type="text" name="keyword" value="${goodsReq.keyword }" placeholder="关键字" class="form-control input-sm">
                          </div>
                          <div class="form-group">
                          	<label>分类:</label>
                             <select class="form-control" name="categoryId">
                             	<option value="0">全部</option>
                             	<c:forEach items="${categoryList}" var="cat" varStatus="catVS">
					            <c:if test="${cat.parentId  eq 0}">
					            	<optgroup label="${cat.title }">
					            		<c:forEach items="${cat.childCategorys}" var="catChild" varStatus="catChildVS">
					            		<option value="${catChild.id }"  <c:if test='${goodsReq.categoryId eq catChild.id }'>selected=selected</c:if> >${catChild.title }</option>
					            		</c:forEach>
					            	</optgroup>
					            </c:if>
                             	</c:forEach>
							</select>
                          </div>
                          <div class="form-group">
                              <input class="btn btn-primary btn-sm" type="submit" value="搜索"/>
                          </div>
                      </form>
                  </div>
                  <div class="ibox-content">
                      <table class="footable table table-stripped toggle-arrow-tiny" data-page-size="10">
                          <thead>
                          <tr>
                          	  <th data-toggle="true">商品ID</th>
                              <th >标题</th>
                              <th>上架状态</th>
                              <th>是否有规格</th>
                              <th data-hide="all">销售价格</th>
                              <th data-hide="all">规格</th>
                              <th data-hide="all">市场价格</th>
                              <th data-hide="all">成本价</th>
                              <th data-hide="all">提成比例</th>
                              <th data-hide="all">库存数</th>
                              <th>操作</th>
                          </tr>
                          </thead>
                          <tbody>
                          <c:forEach items="${list}" var="good" varStatus="vs">
                          <tr>
                              <td>${good.id}</td>
                              <td>${good.title}</td>
                              <td>
                              <c:choose> 
					            <c:when test="${good.isOnsale  eq -1}">已删除</c:when> 
					            <c:when test="${good.isOnsale  eq 0}">未上架 </c:when> 
					            <c:when test="${good.isOnsale  eq 1}">待审核</c:when> 
					            <c:when test="${good.isOnsale  eq 2}">审核失败</c:when> 
					            <c:when test="${good.isOnsale  eq 3}">已上架 </c:when> 
					            <c:when test="${good.isOnsale  eq 4}">已下架</c:when> 
					            <c:when test="${good.isOnsale  eq 5}">审核成功</c:when> 
					          </c:choose>
                              </td>
                              <td>
                              <c:choose>
							       <c:when test="${!empty good.specifications }">有
							       </c:when>
							       <c:when test="${!empty good.specifications }">没有
							       </c:when>
							  </c:choose>
                              </td>
                              <td>${good.salePrice}
                              </td>
                              <td>
                              	<c:choose>
							       <c:when test="${!empty good.specifications }">
							          <table class="table">
			                            <thead>
			                            <tr>
			                                <th>规格ID</th>
			                                <th>规格名称</th>
			                                <th>市场价</th>
			                                <th>销售价</th>
			                                <th>库存数</th>
			                                <th>提成比例</th>
			                                <th>描述</th>
			                            </tr>
			                            </thead>
			                            <tbody>
			                            <c:forEach items="${good.specifications}" var="spe" varStatus="speVS">
			                            <tr>
			                                <td>${spe.id }</td>
			                                <td>${spe.name }</td>
			                                <td>${spe.marketPrice}</td>
			                                <td>${spe.salePrice }</td>
			                                <td>${spe.amount }</td>
			                                <td>${spe.percentageRate }</td>
			                                <td>${spe.desc }</td>
			                            </tr>
			                            </c:forEach>	
			                            </tbody>
			                          </table> 
							       </c:when>
							       <c:when test="${empty good.specifications }">
							              没有规格
							       </c:when>
								</c:choose>
                              </td>
                              <td>${good.marketPrice}</td>
                              <td>${good.costPrice }</td>
                              <td>${good.percentageRate }</td>
                              <td>${good.amount }</td>
                              <td>
                              <a href="${contextPath}/system/good/updateInit/${good.id}" class="btn btn-primary btn-xs">修改</a>
                              <c:choose> 
					            <c:when test="${good.isOnsale  eq -1}"></c:when> 
					            <c:when test="${good.isOnsale  eq 0}">
					            	<c:choose>
					            	   <c:when test="${good.supplierId  eq 0}">
					            	   <a href="${contextPath}/system/good/shelves/${good.id}" class="btn btn-primary btn-xs">上架</a>
					            	    </c:when> 
					            	 </c:choose>
					             </c:when> 
					            <c:when test="${good.isOnsale  eq 1}">
					            	<a href="${contextPath}/system/good/reviewGoodSuccess/${good.id}" class="btn btn-primary btn-xs">审核通过</a>
					            	<a href="${contextPath}/system/good/reviewGoodFail/${good.id}" class="btn btn-primary btn-xs">审核失败</a>
					            </c:when> 
					            <c:when test="${good.isOnsale  eq 2}">
					            </c:when> 
					            <c:when test="${good.isOnsale  eq 3}">
					            	<a href="${contextPath}/system/good/xiajia/${good.id}" class="btn btn-primary btn-xs">下架</a>
					            </c:when>
					            <c:when test="${good.isOnsale  eq 4}">
					            	<a href="${contextPath}/system/good/shelves/${good.id}" class="btn btn-primary btn-xs">上架</a>
					            </c:when> 
					            <c:when test="${good.isOnsale  eq 5}">
					            </c:when>
					          </c:choose>
					          <!-- 添加到首页 限时特惠 或 聚划算  -->
					          <c:choose> 
					            <c:when test="${empty good.marketingActivityList}">
						            <a href="${contextPath}/system/good/marketingActivity/add/${good.id}/1" class="btn btn-primary btn-xs">添加到聚划算</a>
						            <a href="${contextPath}/system/good/marketingActivity/add/${good.id}/2" class="btn btn-primary btn-xs">添加到限时特惠</a>
					            </c:when> 
					            <c:when test="${!empty good.marketingActivityList}">
					            	<c:set var="mark1" value="-1"/>
					          		<c:set var="mark2" value="-1"/>
					            	<c:forEach items="${good.marketingActivityList}" var="ma" varStatus="maVS">
						            	<c:if test="${ma.goodsId eq good.id &&  ma.marketingActivityId eq 1}">
						            		<c:set var="mark1" value="1" />
						            	</c:if>
						            	<c:if test="${ma.goodsId eq good.id && ma.marketingActivityId eq 2}">
						            		<c:set var="mark2" value="2" />
						            	</c:if>
					            	</c:forEach>
					            	<c:if test="${mark1 eq 1}">
					            		<a href="${contextPath}/system/good/marketingActivity/delete/${good.id}/1" class="btn btn-primary btn-xs">从聚划算中删除</a>
					            	</c:if>
					            	<c:if test="${mark1 eq -1}">
					            		<a href="${contextPath}/system/good/marketingActivity/add/${good.id}/1" class="btn btn-primary btn-xs">添加到聚划算</a>
					            	</c:if>
					            	<c:if test="${mark2 eq 2}">
					            		<a href="${contextPath}/system/good/marketingActivity/delete/${good.id}/2" class="btn btn-primary btn-xs">从限时特惠中删除</a>
					            	</c:if>
					            	<c:if test="${mark2 eq -1}">
					            		<a href="${contextPath}/system/good/marketingActivity/add/${good.id}/2" class="btn btn-primary btn-xs">添加到限时特惠</a>
					            	</c:if>
					             </c:when>
					          </c:choose>
                              </td>
                          </tr>
                          </c:forEach>
                          </tbody>
                          <tfoot>
                          <tr>
                              <td colspan="5">
                                  <ul class="pagination pull-right"></ul>
                              </td>
                          </tr>
                          </tfoot>
                      </table>
                  </div>
              </div>
          </div>
      </div>
    </div>
    <script src="${contextPath}/resources/js/jquery.min.js?v=2.1.4"></script>
    <script src="${contextPath}/resources/js/bootstrap.min.js?v=3.3.6"></script>
    <script src="${contextPath}/resources/js/plugins/jeditable/jquery.jeditable.js"></script>
    <script src="${contextPath}/resources/js/plugins/dataTables/jquery.dataTables.js"></script>
    <script src="${contextPath}/resources/js/plugins/dataTables/dataTables.bootstrap.js"></script>
    <script src="${contextPath}/resources/js/content.min.js?v=1.0.0"></script>
    <!-- FooTable -->
    <script src="${contextPath}/resources/js/plugins/footable/footable.all.min.js"></script>
    <!-- Page-Level Scripts -->
    <script>
        $(document).ready(function() {
            $('.footable').footable();
        });
    </script>
</body>
</html>
